using System;
using System.Collections.Generic;
using System.Text;
using System.Data;

namespace DTO
{
	/// <summary> 
	///Author: nnamthach@gmail.com 
	/// <summary>
	
    public class TONHANGInfo
    {
		#region Local Variable
		public enum Field
		{
			MAHANG,
			TENHANG,
			DVTINH,
			SOLUONG,
			SOTIEN,
			GIAVON,
			GIABAN,
			CREATEBY,
			MODIFIEDBY,
			CREATEDATE,
			MODIFIEDDATE
		}
		private String _MAHANG;
		private String _TENHANG;
		private String _DVTINH;
		private Double _SOLUONG;
		private Double _SOTIEN;
		private Double _GIAVON;
		private Double _GIABAN;
		private String _CREATEBY;
		private String _MODIFIEDBY;
		private DateTime _CREATEDATE;
		private DateTime _MODIFIEDDATE;
		
		public String MAHANG{	get{ return _MAHANG;} set{_MAHANG = value;} }
		public String TENHANG{	get{ return _TENHANG;} set{_TENHANG = value;} }
		public String DVTINH{	get{ return _DVTINH;} set{_DVTINH = value;} }
		public Double SOLUONG{	get{ return _SOLUONG;} set{_SOLUONG = value;} }
		public Double SOTIEN{	get{ return _SOTIEN;} set{_SOTIEN = value;} }
		public Double GIAVON{	get{ return _GIAVON;} set{_GIAVON = value;} }
		public Double GIABAN{	get{ return _GIABAN;} set{_GIABAN = value;} }
		public String CREATEBY{	get{ return _CREATEBY;} set{_CREATEBY = value;} }
		public String MODIFIEDBY{	get{ return _MODIFIEDBY;} set{_MODIFIEDBY = value;} }
		public DateTime CREATEDATE{	get{ return _CREATEDATE;} set{_CREATEDATE = value;} }
		public DateTime MODIFIEDDATE{	get{ return _MODIFIEDDATE;} set{_MODIFIEDDATE = value;} }
		
        #endregion LocalVariable
        
        #region Constructor
		public TONHANGInfo()
		{
			_MAHANG = "";
			_TENHANG = "";
			_DVTINH = "";
			_SOLUONG = 0;
			_SOTIEN = 0;
			_GIAVON = 0;
			_GIABAN = 0;
			_CREATEBY = "";
			_MODIFIEDBY = "";
			_CREATEDATE = DateTime.Now;
			_MODIFIEDDATE = DateTime.Now;
		}
		public TONHANGInfo(
		String MAHANG,
		String TENHANG,
		String DVTINH,
		Double SOLUONG,
		Double SOTIEN,
		Double GIAVON,
		Double GIABAN,
		String CREATEBY,
		String MODIFIEDBY,
		DateTime CREATEDATE,
		DateTime MODIFIEDDATE
		)
		{
			_MAHANG = MAHANG;
			_TENHANG = TENHANG;
			_DVTINH = DVTINH;
			_SOLUONG = SOLUONG;
			_SOTIEN = SOTIEN;
			_GIAVON = GIAVON;
			_GIABAN = GIABAN;
			_CREATEBY = CREATEBY;
			_MODIFIEDBY = MODIFIEDBY;
			_CREATEDATE = CREATEDATE;
			_MODIFIEDDATE = MODIFIEDDATE;
		}
		public TONHANGInfo(DataRow dr)
		{
			if (dr != null)
			{
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_TENHANG = dr[Field.TENHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TENHANG.ToString()]);
				_DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DVTINH.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABAN = dr[Field.GIABAN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABAN.ToString()]);
				_CREATEBY = dr[Field.CREATEBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CREATEBY.ToString()]);
				_MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
				_CREATEDATE = dr[Field.CREATEDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CREATEDATE.ToString()]);
				_MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.MODIFIEDDATE.ToString()]);
			}
		}
		public TONHANGInfo(DataRowView dr)
		{
			if (dr != null)
			{
				_MAHANG = dr[Field.MAHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MAHANG.ToString()]);
				_TENHANG = dr[Field.TENHANG.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.TENHANG.ToString()]);
				_DVTINH = dr[Field.DVTINH.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.DVTINH.ToString()]);
				_SOLUONG = dr[Field.SOLUONG.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOLUONG.ToString()]);
				_SOTIEN = dr[Field.SOTIEN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.SOTIEN.ToString()]);
				_GIAVON = dr[Field.GIAVON.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIAVON.ToString()]);
				_GIABAN = dr[Field.GIABAN.ToString()] == DBNull.Value?0:Convert.ToDouble(dr[Field.GIABAN.ToString()]);
				_CREATEBY = dr[Field.CREATEBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.CREATEBY.ToString()]);
				_MODIFIEDBY = dr[Field.MODIFIEDBY.ToString()] == DBNull.Value?"":Convert.ToString(dr[Field.MODIFIEDBY.ToString()]);
				_CREATEDATE = dr[Field.CREATEDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.CREATEDATE.ToString()]);
				_MODIFIEDDATE = dr[Field.MODIFIEDDATE.ToString()] == DBNull.Value?DateTime.Now:Convert.ToDateTime(dr[Field.MODIFIEDDATE.ToString()]);
			}
		}
		public TONHANGInfo(TONHANGInfo objEntr)
		{			
			_MAHANG = objEntr.MAHANG;			
			_TENHANG = objEntr.TENHANG;			
			_DVTINH = objEntr.DVTINH;			
			_SOLUONG = objEntr.SOLUONG;			
			_SOTIEN = objEntr.SOTIEN;			
			_GIAVON = objEntr.GIAVON;			
			_GIABAN = objEntr.GIABAN;			
			_CREATEBY = objEntr.CREATEBY;			
			_MODIFIEDBY = objEntr.MODIFIEDBY;			
			_CREATEDATE = objEntr.CREATEDATE;			
			_MODIFIEDDATE = objEntr.MODIFIEDDATE;			
		}
        #endregion Constructor
        
        #region InitTable
		public static DataTable ToDataTable()
		{
			DataTable dt = new DataTable("TONHANG");
			dt.Columns.AddRange(new DataColumn[] { 
				new DataColumn(Field.MAHANG.ToString(), typeof(String)),
				new DataColumn(Field.TENHANG.ToString(), typeof(String)),
				new DataColumn(Field.DVTINH.ToString(), typeof(String)),
				new DataColumn(Field.SOLUONG.ToString(), typeof(Double)),
				new DataColumn(Field.SOTIEN.ToString(), typeof(Double)),
				new DataColumn(Field.GIAVON.ToString(), typeof(Double)),
				new DataColumn(Field.GIABAN.ToString(), typeof(Double)),
				new DataColumn(Field.CREATEBY.ToString(), typeof(String)),
				new DataColumn(Field.MODIFIEDBY.ToString(), typeof(String)),
				new DataColumn(Field.CREATEDATE.ToString(), typeof(DateTime)),
				new DataColumn(Field.MODIFIEDDATE.ToString(), typeof(DateTime))
			});
			return dt;
		}
		public DataRow ToDataRow(DataTable dt)
		{
			DataRow row = dt.NewRow();
			row[Field.MAHANG.ToString()] = _MAHANG;
			row[Field.TENHANG.ToString()] = _TENHANG;
			row[Field.DVTINH.ToString()] = _DVTINH;
			row[Field.SOLUONG.ToString()] = _SOLUONG;
			row[Field.SOTIEN.ToString()] = _SOTIEN;
			row[Field.GIAVON.ToString()] = _GIAVON;
			row[Field.GIABAN.ToString()] = _GIABAN;
			row[Field.CREATEBY.ToString()] = _CREATEBY;
			row[Field.MODIFIEDBY.ToString()] = _MODIFIEDBY;
			row[Field.CREATEDATE.ToString()] = _CREATEDATE;
			row[Field.MODIFIEDDATE.ToString()] = _MODIFIEDDATE;
			return row;
		}
        #endregion InitTable
    }
}
